﻿#include <CommonUnits/Units/Resistance.h>
#include <gtest/gtest.h>

TEST(ResistanceTest, CastTest)
{
    EXPECT_EQ(CU::Ohm(1e3), CU::Kiloohm(1));
    EXPECT_EQ(CU::Kiloohm(1e3), CU::Megaohm(1));
    EXPECT_EQ(CU::Megaohm(1e3), CU::Gigaohm(1));
    EXPECT_EQ(CU::Gigaohm(1e3), CU::Teraohm(1));
    EXPECT_EQ(CU::Teraohm(1e3), CU::Petaohm(1));
    EXPECT_EQ(CU::Petaohm(1e3), CU::Exaohm(1));
    EXPECT_EQ(CU::Milliohm(1e3), CU::Ohm(1));
    EXPECT_EQ(CU::Microohm(1e3), CU::Milliohm(1));
    EXPECT_EQ(CU::Nanoohm(1e3), CU::Microohm(1));
    EXPECT_EQ(CU::Picoohm(1e3), CU::Nanoohm(1));
    EXPECT_EQ(CU::Femtoohm(1e3), CU::Picoohm(1));
    EXPECT_EQ(CU::Attoohm(1e3), CU::Femtoohm(1));
}

TEST(ResistanceTest, Literals)
{
    using namespace CU::Resistance::Literals;
    EXPECT_EQ(1e3_Ω, 1.0_kΩ);
    EXPECT_EQ(1e3_kΩ, 1.0_MΩ);
    EXPECT_EQ(1e3_MΩ, 1.0_GΩ);
    EXPECT_EQ(1e3_GΩ, 1.0_TΩ);
    EXPECT_EQ(1e3_TΩ, 1.0_PΩ);
    EXPECT_EQ(1e3_PΩ, 1.0_EΩ);
    EXPECT_EQ(1e3_mΩ, 1.0_Ω);
    EXPECT_EQ(1e3_uΩ, 1.0_mΩ);
    EXPECT_EQ(1e3_nΩ, 1.0_uΩ);
    EXPECT_EQ(1e3_pΩ, 1.0_nΩ);
    EXPECT_EQ(1e3_fΩ, 1.0_pΩ);
    EXPECT_EQ(1e3_aΩ, 1.0_fΩ);
}

TEST(ResistanceTest, ToUnit)
{
    using namespace CU::Resistance::Literals;
    EXPECT_EQ(1e3_Ω, CU::Resistance::toUnit<CU::Ohm>(1, CU::Kiloohm::unit()));
    EXPECT_EQ(1e3_kΩ, CU::Resistance::toUnit<CU::Kiloohm>(1, CU::Megaohm::unit()));
    EXPECT_EQ(1e3_MΩ, CU::Resistance::toUnit<CU::Megaohm>(1, CU::Gigaohm::unit()));
    EXPECT_EQ(1e3_GΩ, CU::Resistance::toUnit<CU::Gigaohm>(1, CU::Teraohm::unit()));
    EXPECT_EQ(1e3_TΩ, CU::Resistance::toUnit<CU::Teraohm>(1, CU::Petaohm::unit()));
    EXPECT_EQ(1e3_PΩ, CU::Resistance::toUnit<CU::Petaohm>(1, CU::Exaohm::unit()));
    EXPECT_EQ(1e3_mΩ, CU::Resistance::toUnit<CU::Milliohm>(1, CU::Ohm::unit()));
    EXPECT_EQ(1e3_uΩ, CU::Resistance::toUnit<CU::Microohm>(1, CU::Milliohm::unit()));
    EXPECT_EQ(1e3_nΩ, CU::Resistance::toUnit<CU::Nanoohm>(1, CU::Microohm::unit()));
    EXPECT_EQ(1e3_pΩ, CU::Resistance::toUnit<CU::Picoohm>(1, CU::Nanoohm::unit()));
    EXPECT_EQ(1e3_fΩ, CU::Resistance::toUnit<CU::Femtoohm>(1, CU::Picoohm::unit()));
    EXPECT_EQ(1e3_aΩ, CU::Resistance::toUnit<CU::Attoohm>(1, CU::Femtoohm::unit()));
}

int main(int argc, char* argv[])
{
    testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();
}